package mysql

import "gorm.io/gorm"

type Order struct {
	gorm.Model
	UserId         int    `gorm:"type:int(20);not null;comment:'用户id'"`
	MealProductsId int    `gorm:"type:int(20);not null;comment:'餐品id'"`
	CouponId       int    `gorm:"type:int(20);not null;comment:'优惠券id'"`
	SettlementId   int    `gorm:"type:int(20);not null;comment:'点餐id'"`
	OrderSn        string `gorm:"type:varchar(100);not null;comment:'订单号'"`
	OrderStatus    int    `gorm:"type:int(20);not null;comment:'订单状态： 1:未支付 2:超时未支付 3:已支付 4:已完成'"`
	PayType        int    `gorm:"type:int(20);not null;comment:'支付方式： 1:支付宝 2:微信"`
}

func OrderAdd(order *Order) error {
	return DB.Debug().Create(&order).Error
}

func GetOrderList() (result []*Order, err2 error) {
	DB.Debug().Find(&result)
	return
}
